package com.dgut.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dgut.pojo.Account;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository  //持久层
public interface AccountMapper extends BaseMapper<Account> {
    @Select("select account_id,username,is_locked,create_time,update_time,role from account where username=#{username}")
    Account getAccountByUsername(@Param("username") String username);

    @Results({@Result(column="account_id",property="userInfo",one=@One(select="com.dgut.mapper.UserInfoMapper.selectUserInfoByAccountId"))})
    @Select("select account_id,username,is_locked,create_time,update_time,role from account ${ew.customSqlSegment}")
    List<Account> getAccountWithUserInfo(Page<Account> page, @Param(Constants.WRAPPER) QueryWrapper<Account> wrapper);

}
